package com.tidu.entry;

import lombok.Data;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Map;

import static com.tidu.constants.DocumentConstant.ES_INDEX;

@Data
@Document(indexName = ES_INDEX)
public class ESDocument {
    @Field(type = FieldType.Keyword, index = false)
    private String tableName;
    @Field(type = FieldType.Keyword, index = false)
    private String rowId;
    // 关联数据源（只存ID）
    @Field(type = FieldType.Long)
    private Long sourceId;
    @Field(type = FieldType.Object)
    private Map<String, Object> contentFields;
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String combinedText;

    public ESDocument(String tableName, String rowId, Long sourceId,
                      Map<String, Object> contentFields, String combinedText) {
        this.tableName = tableName;
        this.rowId = rowId;
        this.sourceId = sourceId;
        this.contentFields = contentFields;
        this.combinedText = combinedText;
    }

    /*@Data
    @AllArgsConstructor
    private class MetaData {
    	private String dbType;
    	private String jdbcUrl;
    	private String username;
    	private String password;
    }*/
}